package com.atguigu.jinx.enums;

/**
 * Author:VEGA_KUANGQI
 * <p>
 * 2025/8/13
 */
public enum JobStatus {
    PUBLISHED((byte) 0, "发布中"),
    EXECUTING((byte) 1, "执行中"),
    COMPLETED((byte) 2, "结单"),
    OFF_SHELF((byte) 3, "下架");

    private final byte code;
    private final String description;

    JobStatus(byte code, String description) {
        this.code = code;
        this.description = description;
    }

    public byte getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    // 根据 code 获取枚举
    public static JobStatus fromCode(byte code) {
        for (JobStatus status : JobStatus.values()) {
            if (status.code == code) {
                return status;
            }
        }
        throw new IllegalArgumentException("未知状态码: " + code);
    }
}
